home *** CD-ROM | disk | FTP | other *** search
- /*
- ##########################################################################
- #### ####
- #### The MusicBox Project ####
- #### ============================ ####
- #### ####
- #### MusicBoxJoystick.c ####
- #### ####
- #### Version 2.1os -- September 29, 2000 ####
- #### ####
- #### Copyright (C) 1994 Thomas Dreibholz ####
- #### 2000 Molbachweg 7 ####
- #### 51674 Wiehl ####
- #### Germany ####
- #### ####
- #### EMail: Dreibholz@bigfoot.com ####
- #### WWW: http://www.bigfoot.com/~dreibholz ####
- #### ####
- ##########################################################################
- */
- /***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
- /* Joystick-Kontrolle */
-
- #include "MusicBox.h"
-
- #define JOYSTICK_LEFT (1L<<9)
- #define JOYSTICK_RIGHT (1L<<1)
- #define JOYSTICK_UP (1L<<8)
- #define JOYSTICK_DOWN (1L<<0)
- #define FIRE (1L<<7)
-
- extern struct Einstellungen Einstellungen;
- extern struct RastPort *RPort;
-
- UWORD joy;
- UBYTE fire;
-
- extern BOOL IsIconify;
-
- #asm
- public _GetJ1
- _GetJ1:
- move.w $dff00c,d0
- move.w d0,_joy
-
- btst #7,$bfe001
- bne 1$
- move.b #1,d0
- jmp 2$
- 1$:
- move.b #0,d0
- 2$:
- move.b d0,_fire
- rts
- #endasm
-
- BOOL XOR(a,b)
- UWORD a,b;
- {
- return((a || b) && !(a && b));
- }
-
- BOOL Right()
- {
- if((joy & JOYSTICK_RIGHT)) return(TRUE);
- return(FALSE);
- }
-
- BOOL Left()
- {
- if((joy & JOYSTICK_LEFT)) return(TRUE);
- return(FALSE);
- }
-
- BOOL Up()
- {
- return(XOR(Left(joy),(joy & JOYSTICK_UP)));
- }
-
- BOOL Down()
- {
- return(XOR(Right(joy),(joy & JOYSTICK_DOWN)));
- }
-
- void JoystickHandler()
- {
- REGISTER BOOL bool;
- REGISTER UWORD j;
- REGISTER BYTE x,y,nx,ny;
-
- GetJ1();
- y=x=0;
- if(Left()) x=-1;
- if(Right()) x=1;
- if(Up()) y=1;
- if(Down()) y=-1;
-
- if((x==0)&&(y==0)) return;
-
- if(IsIconify==FALSE)
- {
- SetAPen(RPort,FARBE);
- PutText(5+(3*22),35,"W");
- }
-
- if(Einstellungen.Kontrolle==JOYSTICK_I)
- {
-
- do
- {
- Delay(1);
- GetJ1();
- ny=nx=0;
- if(Left()) nx=-1;
- if(Right()) nx=1;
- if(Up()) ny=1;
- if(Down()) ny=-1;
- }
- while((nx!=0)||(ny!=0));
-
- if(IsIconify==FALSE)
- PutText(5+(3*22),35," ");
-
- if(fire==1) return;
- if(Einstellungen.Funktion==STANDBY) return;
-
- switch(y)
- {
- case 1:
- WiedergabeClicked();
- break;
- case 0:
- switch(x)
- {
- case -1:
- MinusClicked();
- break;
- case 1:
- PlusClicked();
- break;
- }
- break;
- case -1:
- StopClicked();
- break;
- }
- }
- else
- {
- bool=FALSE;
- do
- {
- Delay(1);
- GetJ1();
- ny=nx=0;
- if(Left()) nx=-1;
- if(Right()) nx=1;
- if(Up()) ny=1;
- if(Down()) ny=-1;
- if((nx==0)&&(ny==0)) bool=TRUE;
- if(fire==1) bool=TRUE;
- } while(bool==FALSE);
- bool=FALSE;
- if(ny==-1)
- {
- if(nx!=0)
- {
- if(nx==-1)
- {
- if(Einstellungen.VolumenL>=8)
- Einstellungen.VolumenL-=8;
- else
- Einstellungen.VolumenL=0;
- if(Einstellungen.VolumenR>=8)
- Einstellungen.VolumenR-=8;
- else
- Einstellungen.VolumenR=0;
- }
- else
- {
- if(Einstellungen.VolumenL<=247)
- Einstellungen.VolumenL+=8;
- else
- Einstellungen.VolumenL=255;
- if(Einstellungen.VolumenR<=247)
- Einstellungen.VolumenR+=8;
- else
- Einstellungen.VolumenR=255;
- }
- Volumen();
- ZeigeVolumen();
- return;
- }
- }
-
- do
- {
- Delay(1);
- GetJ1();
- ny=nx=0;
- if(Left()) nx=-1;
- if(Right()) nx=1;
- if(Up()) ny=1;
- if(Down()) ny=-1;
- if((nx==0)&&(ny==0)) bool=TRUE;
- if(fire==0) bool=TRUE;
- } while(bool==FALSE);
-
- if(IsIconify==FALSE)
- PutText(5+(3*22),35," ");
-
- if((nx==0)&&(ny==0)) return;
- if(Einstellungen.Funktion==STANDBY) return;
-
- switch(ny)
- {
- case 1:
- switch(nx)
- {
- case -1:
- RuecklaufClicked();
- break;
- case 0:
- WiedergabeClicked();
- break;
- case 1:
- VorlaufClicked();
- break;
- }
- break;
- case 0:
- if(nx==-1)
- MinusClicked();
- else
- PlusClicked();
- break;
- case -1:
- StopClicked();
- break;
- }
- }
- }
-
-